﻿using System.Collections;
using LuaFramework;
using LuaInterface;
using UnityEngine;


public class ProcUpdateClient : Proc
{
    public static ProcUpdateClient Instance;
    #region Proc
    public override void onBegin(object[] additionalParams)
    {
        Instance = this;
        UpdateClient();
    }

    public override void fixedUpdate()
    {
    }

    public override void process()
    {
    }


    public override void onEnd()
    {
        Instance = null;
    }
    #endregion

    public void UpdateClient()
    {
        AppFacade.Instance.GetManager<ResourceManager>(ManagerName.Resource).Initialize(LoadManager.DATA);
        GameObject go = GameObject.Instantiate(AppFacade.resourceManager.LoadAsset("Res/Internal/Prefab/ui/Login/Loading.prefab")) as GameObject;
        go.name = "LoadingBg";
        go.transform.SetParent(GameObject.Find("init").transform.Find("ScreenCanvas2D/Loading"), false);
        RectTransform rect = go.GetComponent<RectTransform>();
        rect.anchorMin = Vector3.zero;
        rect.anchorMax = Vector3.one;
        rect.offsetMin = Vector3.zero;
        rect.offsetMax = Vector3.zero;
        AppFacade.gameManager.StartCoroutine(DoUpdateClient());
    }

    public IEnumerator DoUpdateClient()
    {
        yield return null;
        AppFacade.gameManager.ChangeState("ProcUpdate", new string[] { "login" });
    }
}
